//package baboo.store;
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);		

//		StringStack stack=new StringStack();
//		LinkedList<String> linkedList=new LinkedList<String>();
		Queue<String> queue=new	 LinkedList<String>();

		System.out.println("input string(end by quit)");

		while(true){
			System.out.print("# ");
			String input=scanner.next();
			if(input.equals("qq"))
				break;
//			stack.push(input);
//			linkedList.addLast(input);
			queue.offer(input);
		}

		System.out.println("show as below");

//		while(!stack.isEmpty()){
//			System.out.print(stack.pop()+" ");
//		}
//		while(!linkedList.isEmpty()){
//			System.out.print(linkedList.getFirst()+" ");
//			linkedList.removeFirst();
//		}
		String element=null;
		while((element=queue.poll())!=null){
			System.out.print(element+" ");
		}

		System.out.println();

	}
}